var SaturnRelSelect = function(funcname){
    this.funcname = funcname;
};  
SaturnRelSelect.prototype ={
 relselect:function(id,relativeid,action,flag){
            if(relativeid!='null'){
              var index = document.getElementById(id).selectedIndex;
  			  var value = document.getElementById(id).options[index].value;
  			  var str = "value="+value;
            }
            else{
           
            	var str=null;
            	var index = action.indexOf("?");
            	
            	if (index > 0) {
            	var param = action.split('?');
            	str = param[1];
            	action = param[0];
            	}
                relativeid = id;
            }
            var myAjax = new Ajax.SaturnRequest(
                	action, 
                {
                    method: 'post',
                    parameters: str,
                    onComplete: this.addAjaxRelSelect,
                    args:relativeid+"_"+this.funcname+"_"+flag
                }
            );
            
    	},
    
    addAjaxRelSelect:function(response,relid){
        var id = relid.split("_")[0];
        var funcname = relid.split("_")[1];
        var flag = relid.split("_")[2];
        var xmlDOM = response.responseXML;
        var root = xmlDOM.documentElement;
    	document.getElementById(id).options.length=0;
        var optionlistlength = root.getElementsByTagName("map").item(0).childNodes.length;
        var element = root.getElementsByTagName("map").item(0).getElementsByTagName("value"); 
        for(var i=0;i<optionlistlength;i++){
        	 document.getElementById(id).add(new Option(element[i].getAttribute("key"),element[i].firstChild.nodeValue));
        }
        
        if(funcname!='undefined'&&flag=='true'){
        	eval(funcname);
        }
    }
};

